package com.nwpusp.display.views.components;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.view.View;

import com.example.petssports.R;
import com.nwpusp.display.GlobalVar;

public class Header extends View{
	
	public Bitmap header;
	public float x;
	public float y;
	public float scale;
	public int headerIndex;
	public float width;
	public float height;
	public int index;
	
	
	public Header(Context view,float scale,int index){
		super(view);
		this.scale = scale;
		this.index = index;
		getBitmapSource();
		header = GlobalVar.VerticalScale(header,scale);
		width = header.getWidth();
		height = header.getHeight();
	}
	
	public void setLocation(float x ,float y){
		this.x = x;
		this.y = y;
	}
	
	private void getBitmapSource(){
		switch(index){     
			case 1:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.xiongmao);
				break;
			}
			case 2:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.niuniu);
				break;
			}
			case 3:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.jiji);
				break;
			}
			case 4:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.tutu);
				break;
			}
			case 5:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.zhuzhu);
				break;
			}
			case 6:{
				header = BitmapFactory.decodeResource(getResources(), R.drawable.yangyang);
				break;
			}
			default:break;
		}
	}
	
	public boolean isClick(float xl,float yl){
		if((xl>x) && (xl<x+width)&&(yl>y)&&(yl<y+height)){
			GlobalVar.Header = index;
			return true;
		}
		else
			return false;
	}

	public Bitmap draw(){
		return header;
	}
	
	

}
